package hot_100;

import java.util.Random;
import java.util.Scanner;

public class 颜色分类 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int n = sc.nextInt();

        int[] nums = new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = r.nextInt(3);
        }
        for (int num : nums) {
            System.out.print(num + " ");
        }
        System.out.println();
        sortColors(nums);
    }

    public static void sortColors(int[] nums) {
        int[] cnt = new int[3];
        for (int i = 0; i < nums.length; i++) {
            int x = nums[i];
            nums[i] = 2;
            if (x <= 1)
                nums[cnt[1]++] = 1;
            if (x <= 0) {
                nums[cnt[0]++] = 0;
            }
        }
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}
